﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace LWP.Chat.Common
{
    public class Command : ICommand
    {

        /// <summary>
        /// 通用的命令
        /// </summary>
        private Action<object> _execute;
        private Func<object, bool> _canExecute;

        public Command(Action<object> execute):this(execute,p=>true)
        {
            
        }

        public Command(Action<object> execute,Func<object,bool> canExecute  )
        {
            _execute = execute;
            _canExecute = canExecute;
        }

        public event EventHandler CanExecuteChanged;

        public bool CanExecute(object parameter)
        {
            return _canExecute(parameter);
        }

        public void OnCanExecuteChanged()
        {
            if (CanExecuteChanged != null)
            {
                CanExecuteChanged(this,EventArgs.Empty);
            }
        }
        public void Execute(object parameter)
        {
            
        }
    }
}
